/**
 * Created by meiyun1 on 2017/8/2.
 */

import Vue from 'vue';

import Config from '@/conf/params';

import axios from 'axios';

import { setData} from '../utils/auth';
import params from '../conf/params'


export default {
  //登录
  doLogin (username, password) {

    var data={
      username,
      password,
      'client_id':'5',
      'client_secret':'Jqb1q1Oc8RaNqyWdNrzE9VvJCPTnfEq5YaGEs7Gr',
      'scope':'',
      'grant_type':'password'
    };

    var params= setData(data);

    return axios.post(`${Config.server}/v1/oauth/token`, params);

  },
  //注销登录
  loginOut (token) {

    return axios.post(`${Config.server}/v1/logout`,null,{
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  },
  getMyProfile (token) {

    // var params=setData({token})

    // return axios.get(`${Config.server}/v1/getMyMessage`,params,{})

   return axios({
      method:'get',
      url:`${Config.server}/v1/getMyMessage`,
      data:{token},
      headers:{
        "Authorization":"Bearer "+token
      }
    });

  }
}
